package com.aierkeji.b2c.dao.jpa.custom.Impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.aierkeji.b2c.dao.jpa.custom.AkjAlipayLifeSnapDaoCustom;
import com.aierkeji.b2c.entity.snapshot.AkjAlipayLifeSnap;

public class AkjAlipayLifeSnapDaoCustomImpl implements AkjAlipayLifeSnapDaoCustom {
	@PersistenceContext
	private EntityManager em;

	public AkjAlipayLifeSnap findFirstLifeByAkjMerchantsOrderByIdDesc(String pId) {
		String hql = "select t from AkjAlipayLifeSnap t where t.delete = 0 and t.akjMerchants.pid= :pId order by t.id desc ";
		AkjAlipayLifeSnap akjAlipayLifeSnap = (AkjAlipayLifeSnap) this.em.createQuery(hql).setParameter("pId", pId).setMaxResults(1).getSingleResult();
		return akjAlipayLifeSnap;
	}
}
